﻿using System.Linq;
using AB.ServiceDirectory.Commons.DataFilters;
using AB.ServiceDirectory.Dao;
using AB.ServiceDirectory.Entities;

namespace AB.ServiceDirectory.BO
{
    /// <summary>
    /// DirectorateBO
    /// </summary>
    public sealed class DirectorateBO
    {
        /// <summary>
        /// 
        /// </summary>
        private static readonly DirectorateDao _directorateDao = new DirectorateDao();

        /// <summary>
        /// Prevents a default instance of the <see cref="DirectorateBO"/> class from being created.
        /// </summary>
        private DirectorateBO()
        {
        }

        /// <summary>
        /// Gets the directorate list.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <param name="sortType">Type of the sort.</param>
        /// <param name="startRowIndex">Start index of the row.</param>
        /// <param name="maxRows">The max rows.</param>
        /// <returns></returns>
        public static IQueryable<Directorate> GetDirectorateList(DirectorateFilter filter, string sortType,
                                                                 int startRowIndex,
                                                                 int maxRows)
        {
            return _directorateDao.GetList(filter, sortType, startRowIndex, maxRows);
        }

        /// <summary>
        /// Gets the list count.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        public static int GetListCount(DirectorateFilter filter)
        {
            return _directorateDao.GetListCount(filter);
        }

        /// <summary>
        /// Gets the directorate by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public static Directorate GetDirectorateById(int id)
        {
            return _directorateDao.GetDirectorateById(id);
        }

        /// <summary>
        /// Adds the directorate.
        /// </summary>
        /// <param name="newDirectorate">The new directorate.</param>
        /// <returns></returns>
        public static bool AddDirectorate(Directorate newDirectorate)
        {
            return _directorateDao.AddDirectorate(newDirectorate);
        }

        /// <summary>
        /// Checks the name of the directorate.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public static bool CheckDirectorateName(string name)
        {
            return _directorateDao.CheckDirectorateName(name);
        }

        /// <summary>
        /// Edits the directorate.
        /// </summary>
        /// <param name="newDirectorate">The new directorate.</param>
        /// <returns></returns>
        public static bool EditDirectorate(Directorate newDirectorate)
        {
            return _directorateDao.EditDirectorate(newDirectorate);
        }

        /// <summary>
        /// Sets the directorate status.
        /// </summary>
        /// <param name="directorateId">The directorate id.</param>
        /// <param name="status">if set to <c>true</c> [status].</param>
        public static void SetDirectorateStatus(int directorateId, bool status)
        {
            _directorateDao.SetDirectorateStatus(directorateId, status);
        }
    }
}